/*
 * @Author: yuanchenxi 836909158@qq.com
 * @Date: 2024-07-24 18:35:54
 * @LastEditors: wanghuan wanghuan@sgsimulation.com
 * @LastEditTime: 2024-09-02 08:42:35
 * @FilePath: \SGFEM\DataStructure\FEM\Element\include\CELAS1Data.h
 */

#pragma once
#include "DataStructure/Common/DataStructureNamespace.h"
#include "DataStructure/Common/Id.h"
#include "DataStructure/Input/Element/ElementBase.h"
#include "DataStructure/Input/Solver/DOFDirections.h"

SG_DATASTRUCTURE_FEM_NAMESPACE_OPEN
/// @brief 标量单元定义
///
/// 可以用来表示标量弹簧，质量或者阻尼单元.
/// m_g1 or m_g2 为 0，表示单元接地
struct DECLSPEC CELAS1Data : public ElementBase
{
    SG::DataStructure::Common::Id  m_pId      = 0;      ///< 属性号
    SG::DataStructure::Common::Id  m_g[2]     = { 0 };  ///< nodes' id
    SG::DataStructure::Common::I64 m_c1       = 0;      ///< 1号点分量方向
    SG::DataStructure::Common::I64 m_c2       = 0;      ///< 2号点分量方向
    SG::DataStructure::Common::Id  m_domainId = 0;

    DOFDirections GetDOF1 () const
    {
        auto dofset = Int2VDofSet (m_c1);
        return dofset[0];
    }

    void SetDOF1 (const SG::DataStructure::FEM::DofSet& dofs)
    {
        m_c1 = DofSet2Int (dofs);
    }

    DOFDirections GetDOF2 () const
    {
        auto dofset = Int2VDofSet (m_c2);
        return dofset[0];
    }

    void SetDOF2 (const SG::DataStructure::FEM::DofSet& dofs)
    {
        m_c2 = DofSet2Int (dofs);
    }
};

/// @brief 判断两个CELAS1Data是否相等
/// @param a
/// @param b
/// @return
DECLSPEC bool operator== (const CELAS1Data& a, const CELAS1Data& b);

SG_DATASTRUCTURE_FEM_NAMESPACE_CLOSE
